<script setup lang="ts">
import type { EChartsCoreOption } from 'echarts'
import { onMounted, Ref, ref } from 'vue'
import { useEcharts } from '@hooks/useChart'
const disChannel: Ref<null | HTMLElement> = ref(null)
const init = () => {
  const options: EChartsCoreOption = {
    title: {
      text: '销售'
    },
    tooltip: {
      trigger: 'item',
      formatter: '{a} <br/>{b} : {c} ({d}%)'
    },
    series: [
      {
        name: '销售占比',
        type: 'pie',
        radius: ['50%', '80%'],
        center: ['45%', '45%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 4
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 25,
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: true
        },
        data: [
          { value: 3000, name: '直播' },
          { value: 600, name: '地推' },
          { value: 1500, name: '网店' },
          { value: 1040, name: '广告' },
          { value: 300, name: '内销' },
          { value: 6000, name: '企业合作' }
        ]
      }
    ]
  }
  useEcharts(disChannel.value as HTMLElement, options)
}
onMounted(init)
</script>
<template>
  <div
    ref="disChannel"
    :style="{
      height: '200px'
    }"
    style="margin: 0 auto"
  ></div>
</template>
<style lang="scss"></style>
